<?php

use yii\db\Migration;

/**
 * Handles the creation of table `vacate`.
 */
class m170612_035143_create_vacate_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        //1.创建请假表格
        $this->createTable('ts_vacate', [
            'id' => $this->primaryKey(),
            'submitter' => $this->string(64)->notNull()->comment('提交人userid'),
            'approver' => $this->string(64)->notNull()->defaultValue('0')->comment('审核人userid'),
            'approved' => $this->smallInteger()->notNull()->defaultValue(0)->comment('1=通过，0=未通过'),
            'reviewer' => $this->string(64)->notNull()->defaultValue('0')->comment('审批人userid'),
            'reviewed' => $this->smallInteger()->notNull()->defaultValue(0)->comment('1=通过，0=未通过'),
            'from_date' => $this->date()->comment('请假开始日期时间'),
            'to_date' => $this->date()->comment('请假结束日期时间'),
            'vacate_type' => $this->smallInteger()->comment('类型3=请假 4=休假'),
            'msg' => $this->string()->comment('请假理由'),
            'create_at' => $this->datetime()->comment('添加时间'),
            ], $tableOptions);
        $this->createIndex('submitter','ts_vacate','submitter');
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('ts_vacate');
    }
}
